package org.softmed.action.resolver;

import java.util.ArrayList;
import java.util.List;

import org.softmed.action.GUIAction;
import org.softmed.action.ActionStep;
import org.softmed.action.description.ActionStepDescription;
import org.softmed.action.states.State;

import com.google.inject.Inject;

public class ActionStepResolverManager {

	@Inject
	List<ActionStepResolver> resolvers = new ArrayList<ActionStepResolver>();

	public ActionStep resolve(ActionStepDescription description)
			throws Throwable {
		ActionStep step = null;
		for (ActionStepResolver resolver : resolvers) {
			step = resolver.instantiate(description);
			if (step != null)
				return step;
		}
		throw new RuntimeException(
				"Could not find a resolver for the ActionStepDescriptor source : "
						+ description.getSource());

	}

	public List<ActionStepResolver> getResolvers() {
		return resolvers;
	}

	public void setResolvers(List<ActionStepResolver> resolvers) {
		this.resolvers = resolvers;
	}

}
